// Copyright 2021 Guoyoko. All Rights Reserved.

#include "Property/SWSphereProperty.h"
#include "SSWDetailPanelContainer.h"
#include "Core/SWDetailBuilder.h"
#include "Slate/SSWPropertyBoolWidget.h"
#include "Slate/SSWPropertyVectorWidget.h"
#include "Slate/SSWPropertyTextWidget.h"
#include "Engine/StaticMeshActor.h"


void FSWSphereProperty::Initialize()
{
	SphereDetailPanel = MakeShareable(new FSWDetailBuilder);

	FSWDetailNode& CategoryStates = SphereDetailPanel->AddCategory("States");

	CategoryStates.AddChildNode("CheckBox", TEXT("CheckBox"), SNew(SSWPropertyBoolWidget, this).NodeName("Visible"));

	CategoryStates.AddChildNode("Vector", TEXT("Vector"), SNew(SSWPropertyVectorWidget, this).NodeName("Location"));

	FSWDetailNode& CategoryDesc = SphereDetailPanel->AddCategory("Desc");
	CategoryDesc.AddChildNode("DataInfo", TEXT("DataInfo"), SNew(SSWPropertyTextWidget, this).NodeName("DataInfo"));

}

bool FSWSphereProperty::TryDisplayDetailPanel(const AActor* InActor)
{
	TSharedPtr<SSWDetailPanelContainer> ContainerPtr = DetailpanelContainer.Pin();
	SelectedActor = nullptr;

	if (Cast<AStaticMeshActor>(InActor)->ActorHasTag("Sphere"))
	{
		SelectedActor = const_cast<AActor*>(InActor);
		ContainerPtr->SetPropertyPanel(SphereDetailPanel->BuildDetail().ToSharedRef());
		return true;
	}

	return false;
}

